home *** CD-ROM | disk | FTP | other *** search
/ Macintosh Technology Seed 1996 September / Macintosh Technology Seed (September 1996) (CDRM1437020).ISO / pc / qd3d15d6 / 15d6_sdk.exe / QD3D Win32 1.5d6 / Interfaces / QD3DPick.h < prev    next >
C/C++ Source or Header  |  1996-08-21  |  12KB  |  417 lines

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DPick.h                                                 **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Public picking routines                                  **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1996 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #ifndef QD3DPick_h
  15. #define QD3DPick_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #include "QD3DStyle.h"
  22. #include "QD3DGeometry.h"
  23.  
  24. #if defined(THINK_C) || defined(__SC__)
  25.     #pragma options(!pack_enums, !align_arrays)
  26.     #pragma SC options align=power
  27. #elif defined(__MWERKS__)
  28.     #pragma enumsalwaysint on
  29.     #pragma align_array_members off
  30.     #pragma options align=native
  31. #elif defined(__PPCC__)
  32.     #pragma options align=power
  33. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  34.     #pragma options enum=int
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif  /*  __cplusplus  */
  40.  
  41.  
  42. /*****************************************************************************
  43.  **                                                                            **
  44.  **                            Mask bits for hit information                     **
  45.  **                                                                            **
  46.  *****************************************************************************/
  47.  
  48. typedef enum TQ3PickDetailMasks {
  49.     kQ3PickDetailNone                    = 0,
  50.     kQ3PickDetailMaskPickID             = 1 << 0,
  51.     kQ3PickDetailMaskPath                 = 1 << 1,
  52.     kQ3PickDetailMaskObject             = 1 << 2,
  53.     kQ3PickDetailMaskLocalToWorldMatrix    = 1 << 3,
  54.     kQ3PickDetailMaskXYZ                 = 1 << 4,
  55.     kQ3PickDetailMaskDistance             = 1 << 5,
  56.     kQ3PickDetailMaskNormal             = 1 << 6,
  57.     kQ3PickDetailMaskShapePart             = 1 << 7,
  58.     kQ3PickDetailMaskPickPart             = 1 << 8,
  59.     kQ3PickDetailMaskUV                 = 1 << 9
  60. #if defined(ESCHER_VER_FUTURE) && (ESCHER_VER_FUTURE)
  61.     ,kQ3PickDetailMaskNeighborhood        = 1 << 10
  62. #endif  /*  ESCHER_VER_FUTURE  */
  63. } TQ3PickDetailMasks;
  64.  
  65. typedef unsigned long TQ3PickDetail;
  66.  
  67.  
  68. /******************************************************************************
  69.  **                                                                             **
  70.  **                                Hitlist sorting                                 **
  71.  **                                                                             **
  72.  *****************************************************************************/
  73.  
  74. typedef enum TQ3PickSort {
  75.     kQ3PickSortNone,
  76.     kQ3PickSortNearToFar,
  77.     kQ3PickSortFarToNear
  78. } TQ3PickSort;
  79.  
  80.  
  81. /******************************************************************************
  82.  **                                                                             **
  83.  **                    Data structures to set up the pick object                 **
  84.  **                                                                             **
  85.  *****************************************************************************/
  86.  
  87. #define kQ3ReturnAllHits        0
  88.  
  89. typedef struct TQ3PickData {
  90.     TQ3PickSort            sort;
  91.     TQ3PickDetail        mask;
  92.     unsigned long        numHitsToReturn;
  93. } TQ3PickData;
  94.  
  95. typedef struct TQ3WindowPointPickData {
  96.     TQ3PickData            data;
  97.     TQ3Point2D            point;
  98.     float                vertexTolerance;
  99.     float                edgeTolerance;
  100. } TQ3WindowPointPickData;
  101.  
  102. typedef struct TQ3WindowRectPickData {
  103.     TQ3PickData            data;
  104.     TQ3Area                rect;
  105. } TQ3WindowRectPickData;
  106.  
  107.  
  108. /******************************************************************************
  109.  **                                                                             **
  110.  **                                    Hit data                                 **
  111.  **                                                                             **
  112.  *****************************************************************************/
  113.  
  114. typedef struct TQ3HitPath {
  115.     TQ3GroupObject            rootGroup;
  116.     unsigned long             depth;
  117.     TQ3GroupPosition        *positions;
  118. } TQ3HitPath;
  119.  
  120. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  121.  
  122. /*
  123.  *    The following data structure has been obsoleted by
  124.  *    the Q3Pick_GetPickDetailData function in conjunction
  125.  *    with the pickDetailValue enum
  126.  */
  127.  
  128. typedef struct TQ3HitData {
  129.     TQ3PickParts            part;
  130.     TQ3PickDetail            validMask;
  131.     unsigned long             pickID;
  132.     TQ3HitPath                path;
  133.     TQ3Object                object;
  134.     TQ3Matrix4x4            localToWorldMatrix;
  135.     TQ3Point3D                xyzPoint;
  136.     float                    distance;
  137.     TQ3Vector3D                normal;
  138.     TQ3ShapePartObject        shapePart;
  139. } TQ3HitData;
  140.     
  141. #endif /* QD3D_OBSOLETE */
  142.  
  143. /******************************************************************************
  144.  **                                                                             **
  145.  **                                Pick class methods                             **
  146.  **                                                                             **
  147.  *****************************************************************************/
  148.  
  149. QD3D_EXPORT TQ3ObjectType Q3Pick_GetType(
  150.     TQ3PickObject        pick);
  151.  
  152. QD3D_EXPORT TQ3Status Q3Pick_GetData(
  153.     TQ3PickObject        pick,
  154.     TQ3PickData            *data);
  155.  
  156. QD3D_EXPORT TQ3Status Q3Pick_SetData(
  157.     TQ3PickObject        pick,
  158.     const TQ3PickData    *data);
  159.     
  160. QD3D_EXPORT TQ3Status Q3Pick_GetVertexTolerance(
  161.     TQ3PickObject        pick,
  162.     float                *vertexTolerance);
  163.     
  164. QD3D_EXPORT TQ3Status Q3Pick_GetEdgeTolerance(
  165.     TQ3PickObject        pick,
  166.     float                *edgeTolerance);
  167.     
  168. QD3D_EXPORT TQ3Status Q3Pick_SetVertexTolerance(
  169.     TQ3PickObject        pick,
  170.     float                vertexTolerance);
  171.     
  172. QD3D_EXPORT TQ3Status Q3Pick_SetEdgeTolerance(
  173.     TQ3PickObject        pick,
  174.     float                edgeTolerance);
  175.  
  176. QD3D_EXPORT TQ3Status Q3Pick_GetNumHits(
  177.     TQ3PickObject        pick,
  178.     unsigned long        *numHits);
  179.  
  180. QD3D_EXPORT TQ3Status Q3Pick_EmptyHitList(
  181.     TQ3PickObject        pick);
  182.  
  183. QD3D_EXPORT TQ3Status Q3Pick_GetPickDetailValidMask(
  184.     TQ3PickObject        pick,
  185.     unsigned long        index,
  186.     TQ3PickDetail        *pickDetailValidMask);
  187.  
  188. QD3D_EXPORT TQ3Status Q3Pick_GetPickDetailData(
  189.     TQ3PickObject        pick,
  190.     unsigned long        index,
  191.     TQ3PickDetail        pickDetailValue,
  192.     void                *detailData);
  193.  
  194. TQ3Status Q3HitPath_EmptyData(
  195.     TQ3HitPath            *hitPath);
  196.  
  197. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  198.  
  199. /*
  200.  *    The following functions have been superseeded
  201.  *    by the Q3Pick_GetPickDetailData function
  202.  */
  203.  
  204. QD3D_EXPORT TQ3Status Q3Pick_GetHitData(
  205.     TQ3PickObject        pick,
  206.     unsigned long        index,
  207.     TQ3HitData            *hitData);
  208.  
  209. QD3D_EXPORT TQ3Status Q3Hit_EmptyData(
  210.     TQ3HitData            *hitData);
  211.     
  212. #endif /* QD3D_OBSOLETE */
  213.     
  214. /******************************************************************************
  215.  **                                                                             **
  216.  **                            Window point pick methods                         **
  217.  **                                                                             **
  218.  *****************************************************************************/
  219.  
  220. QD3D_EXPORT TQ3PickObject Q3WindowPointPick_New(
  221.     const TQ3WindowPointPickData    *data);
  222.  
  223. QD3D_EXPORT TQ3Status Q3WindowPointPick_GetPoint(
  224.     TQ3PickObject                    pick,
  225.     TQ3Point2D                        *point);
  226.  
  227. QD3D_EXPORT TQ3Status Q3WindowPointPick_SetPoint(
  228.     TQ3PickObject                    pick,
  229.     const TQ3Point2D                *point);
  230.  
  231. QD3D_EXPORT TQ3Status Q3WindowPointPick_GetData(
  232.     TQ3PickObject                    pick,
  233.     TQ3WindowPointPickData            *data);
  234.  
  235. QD3D_EXPORT TQ3Status Q3WindowPointPick_SetData(
  236.     TQ3PickObject                    pick,
  237.     const TQ3WindowPointPickData    *data);
  238.  
  239.  
  240. /******************************************************************************
  241.  **                                                                             **
  242.  **                            Window rect pick methods                         **
  243.  **                                                                             **
  244.  *****************************************************************************/
  245.  
  246. QD3D_EXPORT TQ3PickObject Q3WindowRectPick_New(
  247.     const TQ3WindowRectPickData    *data);
  248.  
  249. QD3D_EXPORT TQ3Status Q3WindowRectPick_GetRect(
  250.     TQ3PickObject                pick,
  251.     TQ3Area                        *rect);
  252.  
  253. QD3D_EXPORT TQ3Status Q3WindowRectPick_SetRect(
  254.     TQ3PickObject                pick,
  255.     const TQ3Area                *rect);
  256.  
  257. QD3D_EXPORT TQ3Status Q3WindowRectPick_GetData(
  258.     TQ3PickObject                pick,
  259.     TQ3WindowRectPickData        *data);
  260.  
  261. QD3D_EXPORT TQ3Status Q3WindowRectPick_SetData(
  262.     TQ3PickObject                pick,
  263.     const TQ3WindowRectPickData    *data);
  264.  
  265.  
  266. #if defined(ESCHER_VER_FUTURE) && ESCHER_VER_FUTURE
  267.  
  268. /******************************************************************************
  269.  **                                                                             **
  270.  **                    Data structures to set up the pick object                 **
  271.  **                                                                             **
  272.  *****************************************************************************/
  273.  
  274. typedef struct TQ3BoxPickData {
  275.     TQ3PickData            data;
  276.     TQ3BoundingBox        box;
  277. } TQ3BoxPickData;
  278.  
  279. typedef struct TQ3RayPickData {
  280.     TQ3PickData            data;
  281.     TQ3Ray3D            ray;
  282.     float                vertexTolerance;
  283.     float                edgeTolerance;
  284. } TQ3RayPickData;
  285.  
  286. typedef struct TQ3SpherePickData {
  287.     TQ3PickData            data;
  288.     TQ3BoundingSphere    sphere;
  289.     float                vertexTolerance;
  290.     float                edgeTolerance;
  291. } TQ3SpherePickData;
  292.  
  293.  
  294. /******************************************************************************
  295.  **                                                                             **
  296.  **                        World-space box pick methods                         **
  297.  **                                                                             **
  298.  *****************************************************************************/
  299.     
  300. QD3D_EXPORT TQ3PickObject Q3BoxPick_New(
  301.     const TQ3BoxPickData    *data);
  302.  
  303. QD3D_EXPORT TQ3Status Q3BoxPick_GetBox(
  304.     TQ3PickObject            pick,
  305.     TQ3BoundingBox            *box);
  306.  
  307. QD3D_EXPORT TQ3Status Q3BoxPick_SetBox(
  308.     TQ3PickObject            pick,
  309.     const TQ3BoundingBox    *box);
  310.  
  311. QD3D_EXPORT TQ3Status Q3BoxPick_GetData(
  312.     TQ3PickObject            pick,
  313.     TQ3BoxPickData            *data);
  314.  
  315. QD3D_EXPORT TQ3Status Q3BoxPick_SetData(
  316.     TQ3PickObject            pick,
  317.     const TQ3BoxPickData    *data);
  318.     
  319.     
  320. /******************************************************************************
  321.  **                                                                             **
  322.  **                        World-space ray pick methods                         **
  323.  **                                                                             **
  324.  *****************************************************************************/
  325.  
  326. QD3D_EXPORT TQ3PickObject Q3RayPick_New(
  327.     const TQ3RayPickData    *data);
  328.  
  329. QD3D_EXPORT TQ3Status Q3RayPick_GetRay(
  330.     TQ3PickObject            pick,
  331.     TQ3Ray3D                *ray);
  332.  
  333. QD3D_EXPORT TQ3Status Q3RayPick_SetRay(
  334.     TQ3PickObject            pick,
  335.     const TQ3Ray3D            *ray);
  336.  
  337. QD3D_EXPORT TQ3Status Q3RayPick_GetData(
  338.     TQ3PickObject            pick,
  339.     TQ3RayPickData            *data);
  340.  
  341. QD3D_EXPORT TQ3Status Q3RayPick_SetData(
  342.     TQ3PickObject            pick,
  343.     const TQ3RayPickData    *data);
  344.  
  345.  
  346. /******************************************************************************
  347.  **                                                                             **
  348.  **                        World-space sphere pick methods                         **
  349.  **                                                                             **
  350.  *****************************************************************************/
  351.  
  352. QD3D_EXPORT TQ3PickObject Q3SpherePick_New(
  353.     const TQ3SpherePickData        *data);
  354.  
  355. QD3D_EXPORT TQ3Status Q3SpherePick_GetSphere(
  356.     TQ3PickObject                pick,
  357.     TQ3BoundingSphere            *sphere);
  358.  
  359. QD3D_EXPORT TQ3Status Q3SpherePick_SetSphere(
  360.     TQ3PickObject                pick,
  361.     const TQ3BoundingSphere        *sphere);
  362.  
  363. QD3D_EXPORT TQ3Status Q3SpherePick_GetData(
  364.     TQ3PickObject                pick,
  365.     TQ3SpherePickData            *data);
  366.  
  367. QD3D_EXPORT TQ3Status Q3SpherePick_SetData(
  368.     TQ3PickObject                pick,
  369.     const TQ3SpherePickData        *data);
  370.  
  371. #endif    /* ESCHER_VER_FUTURE */
  372.  
  373.  
  374. /******************************************************************************
  375.  **                                                                             **
  376.  **                                Shape Part methods                             **
  377.  **                                                                             **
  378.  *****************************************************************************/
  379.  
  380. QD3D_EXPORT TQ3ObjectType Q3ShapePart_GetType(
  381.     TQ3ShapePartObject            shapePartObject);
  382.  
  383. QD3D_EXPORT TQ3ObjectType Q3MeshPart_GetType(
  384.     TQ3MeshPartObject            meshPartObject);
  385.  
  386. QD3D_EXPORT TQ3Status Q3ShapePart_GetShape(
  387.     TQ3ShapePartObject            shapePartObject,
  388.     TQ3ShapeObject                *shapeObject);
  389.  
  390. QD3D_EXPORT TQ3Status Q3MeshPart_GetComponent(
  391.     TQ3MeshPartObject            meshPartObject,
  392.     TQ3MeshComponent            *component);
  393.  
  394. QD3D_EXPORT TQ3Status Q3MeshFacePart_GetFace(
  395.     TQ3MeshFacePartObject        meshFacePartObject,
  396.     TQ3MeshFace                    *face);
  397.  
  398. QD3D_EXPORT TQ3Status Q3MeshEdgePart_GetEdge(
  399.     TQ3MeshEdgePartObject        meshEdgePartObject,
  400.     TQ3MeshEdge                    *edge);
  401.  
  402. QD3D_EXPORT TQ3Status Q3MeshVertexPart_GetVertex(
  403.     TQ3MeshVertexPartObject        meshVertexPartObject,
  404.     TQ3MeshVertex                *vertex);
  405.  
  406. #ifdef __cplusplus
  407. }
  408. #endif  /*  __cplusplus  */
  409.  
  410. #if defined(__MWERKS__)
  411.     #pragma enumsalwaysint reset
  412. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  413.     #pragma options enum=reset
  414. #endif
  415.  
  416. #endif  /*  QD3DPick_h  */
  417.